package com.interesting.examsystem.common.response;

/**
 * @author ：ZXY
 * @date ：Created in 2021/2/22 16:36
 * @description：返回结果
 * @modified By：`
 * @version: 1.0
 */
import com.alibaba.fastjson.JSON;

public class Result {
    private Integer code;
    private boolean success;
    private String resultCode;
    private String msg;
    private Object data;

    public Integer getCode() {
        return this.code;
    }

    public boolean isSuccess() {
        return this.success;
    }

    public String getResultCode() {
        return this.resultCode;
    }

    public String getMsg() {
        return this.msg;
    }

    public Object getData() {
        return this.data;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(Object data) {
        this.data = data;
    }

    private Result(Builder builder) {
        this.success = true;

        this.success = builder.success.booleanValue();
        this.code = builder.code;
        this.msg = builder.msg;
        this.data = builder.data;
        this.resultCode = builder.resultCode;
    }

    public Result(Builder builder, Object o) {
        this.success = true;
    }

    public static class Builder {
        private Boolean success;
        private final Integer code;
        private String msg;
        private Object data;
        private String resultCode;

        public Builder(Integer code) {
            this.code = code;
        }

        public Builder success(boolean success) {
            this.success = Boolean.valueOf(success);
            return this;
        }

        public Builder msg(String msg) {
            this.msg = msg;
            return this;
        }

        public Builder rows(Object data) {
            this.data = data;
            return this;
        }

        public Builder resultCode(String resultCode) {
            this.resultCode = resultCode;
            return this;
        }

        public Result build() {
            return new Result(this);
        }
    }

    public String toString() {
        return JSON.toJSONString(this);
    }
}
